package com.hhkj.admin.order.model.dopo;

import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.hhkj.admin.order.common.cont.OrderConst;
import com.hhkj.admin.order.domain.Order;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.util.Date;
import java.util.List;

@EqualsAndHashCode(callSuper = true)
@Data
public class OrderDo extends Order {

    /** 订单状态列表paying-支付中，paidAuditing-支付审核中，paid-已支付，cancel-已取消 */
    private List<String> statusCodeList;

    /** 子订单查询条件 */
    private OrderItemDo orderItemDo;

    /** 商家编号或者名称 **/
    private String sale;

    /** 创建日期范围 **/
    @JsonFormat(pattern = "yyyy-MM-dd")
    private Date createDateStart;

    /** 创建日期范围 **/
    @JsonFormat(pattern = "yyyy-MM-dd")
    private Date createDateEnd;

    /** 创建时间范围 **/
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date createTimeStart;

    /** 创建时间范围 **/
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date createTimeEnd;

    /** 支付日期开始时间 */
    @JsonFormat(pattern = "yyyy-MM-dd")
    private Date payDateStart;

    /** 支付日期结束时间 */
    @JsonFormat(pattern = "yyyy-MM-dd")
    private Date payDateEnd;

    public void setCreateDateEnd(Date createDateEnd) {
        if (ObjectUtil.isNotEmpty(createDateEnd)) {
            this.createDateEnd = DateUtil.offsetMillisecond(DateUtil.offsetDay(createDateEnd, 1), -1);
        }
    }
}
